namespace AutoClub.Core.Migrations
{
    using System.Data.Entity.Migrations;

    public partial class InitialSetup : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Mechanics",
                c => new
                    {
                        Id = c.Guid(nullable: false, identity: true),
                        Name = c.String(),
                        LastName = c.String(),
                        Dni = c.String(),
                        Active = c.Boolean(nullable: false),
                        CreatedBy = c.String(nullable: false),
                        CreatedOn = c.DateTimeOffset(nullable: false),
                    })
                .PrimaryKey(t => t.Id);

            CreateTable(
                "dbo.Races",
                c => new
                    {
                        Id = c.Guid(nullable: false, identity: true),
                        StartDate = c.DateTimeOffset(nullable: false),
                        EndDate = c.DateTimeOffset(),
                        MechanicsMaxAmount = c.Int(nullable: false),
                        Active = c.Boolean(nullable: false),
                        CreatedBy = c.String(nullable: false),
                        CreatedOn = c.DateTimeOffset(nullable: false),
                    })
                .PrimaryKey(t => t.Id);

            CreateTable(
                "dbo.Users",
                c => new
                    {
                        Id = c.Guid(nullable: false, identity: true),
                        Email = c.String(),
                        Password = c.String(),
                        Active = c.Boolean(nullable: false),
                        CreatedBy = c.String(nullable: false),
                        CreatedOn = c.DateTimeOffset(nullable: false),
                    })
                .PrimaryKey(t => t.Id);

            CreateTable(
                "dbo.RaceMechanics",
                c => new
                    {
                        Id = c.Guid(nullable: false, identity: true),
                        Active = c.Boolean(nullable: false),
                        CreatedBy = c.String(nullable: false),
                        CreatedOn = c.DateTimeOffset(nullable: false),
                        Race_Id = c.Guid(),
                        Mechanic_Id = c.Guid(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Races", t => t.Race_Id)
                .ForeignKey("dbo.Mechanics", t => t.Mechanic_Id)
                .Index(t => t.Race_Id)
                .Index(t => t.Mechanic_Id);

        }

        public override void Down()
        {
            DropIndex("dbo.RaceMechanics", new[] { "Mechanic_Id" });
            DropIndex("dbo.RaceMechanics", new[] { "Race_Id" });
            DropForeignKey("dbo.RaceMechanics", "Mechanic_Id", "dbo.Mechanics");
            DropForeignKey("dbo.RaceMechanics", "Race_Id", "dbo.Races");
            DropTable("dbo.RaceMechanics");
            DropTable("dbo.Users");
            DropTable("dbo.Races");
            DropTable("dbo.Mechanics");
        }
    }
}
